import requests
from decimal import Decimal
import re



base_url='http://calculator.webapp.163.com/xyq_mnjd_gj/mnjdgjs?callback=jQuery1640018944610373485604_1632617639659&zz={}&gj0={}&czl={}&lv={}&_=1632619393826'

def ji_suan(zizhi,liliang,chengzhang,level):
    #print('资质: {} === 力量 : {} =====成长: {} =====等级: {}'.format(zizhi.__str__(), liliang.__str__(), chengzhang.__str__(), level.__str__()))
    full_url = base_url.format(zizhi, liliang, chengzhang, level)
    html = requests.get(full_url)
    # print(full_url)
    s = re.findall("\d+", html.text)[0]
    # gongji = (Decimal(chengzhang) * Decimal(liliang) / Decimal(1000)) + (
    #             Decimal(zizhi) * Decimal(level) * Decimal(3.2) / Decimal(1000))

    gongji = (Decimal(chengzhang) * Decimal(liliang) / Decimal(1000)) + (Decimal(zizhi) * Decimal(level) *(Decimal(14)+Decimal(10)*(Decimal(chengzhang)/Decimal(1000)))  )/ Decimal(7500)
    chazhi = int(s) - gongji
    print('自算: {} === 官方 : {} =====差值: {}'.format(gongji.__str__(), s, chazhi.__str__()))
    #print('差值: {}'.format(chazhi.__str__()))
    return  gongji;



#ji_suan(1345,609,1230,113)


if __name__ == '__main__':

    #力量差
    # for x in range(0,1000,100):
    #     ji_suan(1000,x,1264,119)
    #成长差
    # for x in range(1000,1300,10):
    #     ji_suan(1000,129,x,119)
    # #等级差
    for x in range(0,119,1):
       ji_suan(1000,x+10,1264,x)
    # #资质差
    last_gongji=0
    # for x in range(1000,1700,100):
    #     now_gongji=ji_suan(x,129,1264,119)
    #     print(" 119级1.264成长 100点资质差额 =={} ",now_gongji-last_gongji)
    #
    #     now_gongji=ji_suan(x,129,1230,119)
    #     print(" 119级1.23成长 10点资质差额 =={} ",now_gongji-last_gongji)
    #
    #     last_gongji=now_gongji


def jisuan_yinshu(chengzhang,gongzi):
    return gongzi*(14+10*chengzhang/1000)/7500

for x in range(1000,1700,100):
    # print(jisuan_yinshu(1.264,x)*119)
    # print(*119)
    last_asd=0
    for y in range(1200,1264,10):
        print('119情况下 : {} 资质下 0.01 成长 总攻击为{} 攻击力差为{}'.format(x ,jisuan_yinshu(y, x)*119,jisuan_yinshu(y, x)*119-last_asd))
        last_asd=jisuan_yinshu(y, x)*119
